package org.example.study.sc.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.ibatis.annotations.Param;
import org.example.study.sc.entity.GoodsStock;
import org.example.study.sc.mapper.GoodsStockMapper;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @program: rabbitmq-study
 * @description:
 * @Version V1.0.0
 * @author: dazhi
 * @create: 2021-02-01 11:00
 **/
@Service
public class GoodsStockService extends ServiceImpl<GoodsStockMapper, GoodsStock> {

    public List<GoodsStock> findStocksForUpdate(List<Long> itemIds) {
        return this.baseMapper.findStockForUpdate(itemIds);
    }


    public Boolean updateStock(GoodsStock stock) {
        return this.baseMapper.updateStock(stock) > 0;
    }

    public GoodsStock getByIdForUpdate(@Param("goodsId") Long goodsId) {
        return this.baseMapper.getByIdForUpdate(goodsId);
    }


}
